SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblLanguages]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblLanguages](
	[ID_Language] [int] IDENTITY(1,1) NOT NULL,
	[Description] [varchar](200) NOT NULL,
 CONSTRAINT [PK_tblLanguages] PRIMARY KEY CLUSTERED 
(
	[ID_Language] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblPlatform]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblPlatform](
	[Platform_ID] [int] IDENTITY(1,1) NOT NULL,
	[Description] [varchar](200) NOT NULL,
 CONSTRAINT [PK_tblPlatform] PRIMARY KEY CLUSTERED 
(
	[Platform_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblSkills]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblSkills](
	[Skill_ID] [int] IDENTITY(1,1) NOT NULL,
	[Description] [varchar](200) NOT NULL,
 CONSTRAINT [PK_tblSkills] PRIMARY KEY CLUSTERED 
(
	[Skill_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblTechnologies]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblTechnologies](
	[Technology_ID] [int] IDENTITY(1,1) NOT NULL,
	[Description] [varchar](200) NOT NULL,
 CONSTRAINT [PK_tblTechnologies] PRIMARY KEY CLUSTERED 
(
	[Technology_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblTags]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblTags](
	[Tags_ID] [int] IDENTITY(1,1) NOT NULL,
	[Description] [varchar](200) NOT NULL,
 CONSTRAINT [PK_tblCategories] PRIMARY KEY CLUSTERED 
(
	[Tags_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblPublisher]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblPublisher](
	[Publisher_ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](150) NOT NULL,
	[Username] [varchar](20) NOT NULL,
	[Password] [varchar](50) NOT NULL,
	[Email] [varchar](200) NOT NULL,
	[Member] [bit] NOT NULL,
 CONSTRAINT [PK_tblPublisher] PRIMARY KEY CLUSTERED 
(
	[Publisher_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblArticlesTag]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblArticlesTag](
	[Article_ID] [int] NOT NULL,
	[Tags_ID] [int] NOT NULL,
 CONSTRAINT [PK_tblArticlesTag] PRIMARY KEY CLUSTERED 
(
	[Article_ID] ASC,
	[Tags_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblArticlesLanguage]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblArticlesLanguage](
	[Article_ID] [int] NOT NULL,
	[Language_ID] [int] NOT NULL,
 CONSTRAINT [PK_tblArticlesLanguage] PRIMARY KEY CLUSTERED 
(
	[Article_ID] ASC,
	[Language_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblArticlesPlatform]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblArticlesPlatform](
	[Article_ID] [int] NOT NULL,
	[Patform_ID] [int] NOT NULL,
 CONSTRAINT [PK_tblArticlesPlatform] PRIMARY KEY CLUSTERED 
(
	[Article_ID] ASC,
	[Patform_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblArticlesSkill]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblArticlesSkill](
	[Article_ID] [int] NOT NULL,
	[Skill_ID] [int] NOT NULL,
 CONSTRAINT [PK_tblArticleSkill] PRIMARY KEY CLUSTERED 
(
	[Article_ID] ASC,
	[Skill_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblArticlesTech]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblArticlesTech](
	[Article_ID] [int] NOT NULL,
	[Technology_ID] [int] NOT NULL,
 CONSTRAINT [PK_tblArticlesTech] PRIMARY KEY CLUSTERED 
(
	[Article_ID] ASC,
	[Technology_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblComments]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblComments](
	[Comment_ID] [int] IDENTITY(1,1) NOT NULL,
	[Article_ID] [int] NOT NULL,
	[Publisher_ID] [int] NOT NULL,
	[CommentText] [varchar](max) NOT NULL,
	[AlertMe] [bit] NOT NULL CONSTRAINT [DF_tblComments_AlertMe]  DEFAULT ((0)),
 CONSTRAINT [PK_tblComments] PRIMARY KEY CLUSTERED 
(
	[Comment_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblWarningAdviser]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblWarningAdviser](
	[Article_ID] [int] NOT NULL,
	[Publisher_ID] [int] NOT NULL,
 CONSTRAINT [PK_tblWarningAdviser] PRIMARY KEY CLUSTERED 
(
	[Article_ID] ASC,
	[Publisher_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblArticlesGrouped]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblArticlesGrouped](
	[Article_ID] [int] NOT NULL,
	[Group_ID] [int] NOT NULL,
 CONSTRAINT [PK_tblArticlesGrouped] PRIMARY KEY CLUSTERED 
(
	[Article_ID] ASC,
	[Group_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblGroups]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblGroups](
	[Group_ID] [int] IDENTITY(1,1) NOT NULL,
	[GroupOwner] [int] NOT NULL,
	[Description] [varchar](250) NOT NULL,
 CONSTRAINT [PK_tblGroups] PRIMARY KEY CLUSTERED 
(
	[Group_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblArticles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblArticles](
	[Article_ID] [int] IDENTITY(1,1) NOT NULL,
	[Publisher_ID] [int] NOT NULL,
	[Path] [varchar](255) NOT NULL,
	[Title] [varchar](200) NOT NULL,
	[Short_Description] [varchar](max) NOT NULL,
	[Publish_Date] [smalldatetime] NOT NULL,
	[AllowedToPublish] [bit] NOT NULL CONSTRAINT [DF_tblArticles_AllowedToPublish]  DEFAULT ((0)),
	[TotalVisits] [int] NOT NULL CONSTRAINT [DF_tblArticles_TotalVisits]  DEFAULT ((1)),
	[TotalPoints] [int] NOT NULL CONSTRAINT [DF_tblArticles_TotalPoints]  DEFAULT ((3)),
	[TotalVotes] [int] NOT NULL CONSTRAINT [DF_tblArticles_TotalVotes]  DEFAULT ((1)),
 CONSTRAINT [PK_tblArticles] PRIMARY KEY CLUSTERED 
(
	[Article_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[InsertNewArticle]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-- =============================================
-- Author:		Matias Iacono
-- Create date: 21/09/2008
-- Description:	
-- =============================================
CREATE PROCEDURE [dbo].[InsertNewArticle] 
	@Publisher_ID int, 
	@Path varchar(255),
	@Title varchar(200),
	@Short_Description varchar(max),
	@Publish_Date smalldatetime,
	@AllowedToPublish bit	
AS
BEGIN
	SET NOCOUNT ON;

	INSERT INTO tblArticles(Publisher_ID, [Path], Title,
		Short_Description, Publish_Date, AllowedToPublish, TotalVisits,
		TotalPoints, TotalVotes)
		VALUES (@Publisher_ID, @Path, @Title, @Short_Description, @Publish_Date,
			@AllowedToPublish, 1, 3, 1);

	SELECT @@IDENTITY AS ArticleID;
END
' 
END
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblArticlesTag_tblArticles]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblArticlesTag]'))
ALTER TABLE [dbo].[tblArticlesTag]  WITH CHECK ADD  CONSTRAINT [FK_tblArticlesTag_tblArticles] FOREIGN KEY([Article_ID])
REFERENCES [dbo].[tblArticles] ([Article_ID])
GO
ALTER TABLE [dbo].[tblArticlesTag] CHECK CONSTRAINT [FK_tblArticlesTag_tblArticles]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblArticlesTag_tblTags]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblArticlesTag]'))
ALTER TABLE [dbo].[tblArticlesTag]  WITH CHECK ADD  CONSTRAINT [FK_tblArticlesTag_tblTags] FOREIGN KEY([Tags_ID])
REFERENCES [dbo].[tblTags] ([Tags_ID])
GO
ALTER TABLE [dbo].[tblArticlesTag] CHECK CONSTRAINT [FK_tblArticlesTag_tblTags]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblArticlesLanguage_tblArticles]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblArticlesLanguage]'))
ALTER TABLE [dbo].[tblArticlesLanguage]  WITH CHECK ADD  CONSTRAINT [FK_tblArticlesLanguage_tblArticles] FOREIGN KEY([Article_ID])
REFERENCES [dbo].[tblArticles] ([Article_ID])
GO
ALTER TABLE [dbo].[tblArticlesLanguage] CHECK CONSTRAINT [FK_tblArticlesLanguage_tblArticles]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblArticlesLanguage_tblLanguages]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblArticlesLanguage]'))
ALTER TABLE [dbo].[tblArticlesLanguage]  WITH CHECK ADD  CONSTRAINT [FK_tblArticlesLanguage_tblLanguages] FOREIGN KEY([Language_ID])
REFERENCES [dbo].[tblLanguages] ([ID_Language])
GO
ALTER TABLE [dbo].[tblArticlesLanguage] CHECK CONSTRAINT [FK_tblArticlesLanguage_tblLanguages]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblArticlesPlatform_tblArticles]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblArticlesPlatform]'))
ALTER TABLE [dbo].[tblArticlesPlatform]  WITH CHECK ADD  CONSTRAINT [FK_tblArticlesPlatform_tblArticles] FOREIGN KEY([Article_ID])
REFERENCES [dbo].[tblArticles] ([Article_ID])
GO
ALTER TABLE [dbo].[tblArticlesPlatform] CHECK CONSTRAINT [FK_tblArticlesPlatform_tblArticles]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblArticlesPlatform_tblPlatform]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblArticlesPlatform]'))
ALTER TABLE [dbo].[tblArticlesPlatform]  WITH CHECK ADD  CONSTRAINT [FK_tblArticlesPlatform_tblPlatform] FOREIGN KEY([Patform_ID])
REFERENCES [dbo].[tblPlatform] ([Platform_ID])
GO
ALTER TABLE [dbo].[tblArticlesPlatform] CHECK CONSTRAINT [FK_tblArticlesPlatform_tblPlatform]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblArticlesSkill_tblArticles]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblArticlesSkill]'))
ALTER TABLE [dbo].[tblArticlesSkill]  WITH CHECK ADD  CONSTRAINT [FK_tblArticlesSkill_tblArticles] FOREIGN KEY([Article_ID])
REFERENCES [dbo].[tblArticles] ([Article_ID])
GO
ALTER TABLE [dbo].[tblArticlesSkill] CHECK CONSTRAINT [FK_tblArticlesSkill_tblArticles]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblArticlesSkill_tblSkills]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblArticlesSkill]'))
ALTER TABLE [dbo].[tblArticlesSkill]  WITH CHECK ADD  CONSTRAINT [FK_tblArticlesSkill_tblSkills] FOREIGN KEY([Skill_ID])
REFERENCES [dbo].[tblSkills] ([Skill_ID])
GO
ALTER TABLE [dbo].[tblArticlesSkill] CHECK CONSTRAINT [FK_tblArticlesSkill_tblSkills]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblArticlesTech_tblArticles]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblArticlesTech]'))
ALTER TABLE [dbo].[tblArticlesTech]  WITH CHECK ADD  CONSTRAINT [FK_tblArticlesTech_tblArticles] FOREIGN KEY([Article_ID])
REFERENCES [dbo].[tblArticles] ([Article_ID])
GO
ALTER TABLE [dbo].[tblArticlesTech] CHECK CONSTRAINT [FK_tblArticlesTech_tblArticles]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblArticlesTech_tblTechnologies]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblArticlesTech]'))
ALTER TABLE [dbo].[tblArticlesTech]  WITH CHECK ADD  CONSTRAINT [FK_tblArticlesTech_tblTechnologies] FOREIGN KEY([Technology_ID])
REFERENCES [dbo].[tblTechnologies] ([Technology_ID])
GO
ALTER TABLE [dbo].[tblArticlesTech] CHECK CONSTRAINT [FK_tblArticlesTech_tblTechnologies]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblComments_tblArticles]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblComments]'))
ALTER TABLE [dbo].[tblComments]  WITH CHECK ADD  CONSTRAINT [FK_tblComments_tblArticles] FOREIGN KEY([Article_ID])
REFERENCES [dbo].[tblArticles] ([Article_ID])
GO
ALTER TABLE [dbo].[tblComments] CHECK CONSTRAINT [FK_tblComments_tblArticles]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblComments_tblPublisher]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblComments]'))
ALTER TABLE [dbo].[tblComments]  WITH CHECK ADD  CONSTRAINT [FK_tblComments_tblPublisher] FOREIGN KEY([Publisher_ID])
REFERENCES [dbo].[tblPublisher] ([Publisher_ID])
GO
ALTER TABLE [dbo].[tblComments] CHECK CONSTRAINT [FK_tblComments_tblPublisher]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblWarningAdviser_tblArticles]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblWarningAdviser]'))
ALTER TABLE [dbo].[tblWarningAdviser]  WITH CHECK ADD  CONSTRAINT [FK_tblWarningAdviser_tblArticles] FOREIGN KEY([Article_ID])
REFERENCES [dbo].[tblArticles] ([Article_ID])
GO
ALTER TABLE [dbo].[tblWarningAdviser] CHECK CONSTRAINT [FK_tblWarningAdviser_tblArticles]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblWarningAdviser_tblPublisher]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblWarningAdviser]'))
ALTER TABLE [dbo].[tblWarningAdviser]  WITH CHECK ADD  CONSTRAINT [FK_tblWarningAdviser_tblPublisher] FOREIGN KEY([Publisher_ID])
REFERENCES [dbo].[tblPublisher] ([Publisher_ID])
GO
ALTER TABLE [dbo].[tblWarningAdviser] CHECK CONSTRAINT [FK_tblWarningAdviser_tblPublisher]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblArticlesGrouped_tblArticles]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblArticlesGrouped]'))
ALTER TABLE [dbo].[tblArticlesGrouped]  WITH CHECK ADD  CONSTRAINT [FK_tblArticlesGrouped_tblArticles] FOREIGN KEY([Article_ID])
REFERENCES [dbo].[tblArticles] ([Article_ID])
GO
ALTER TABLE [dbo].[tblArticlesGrouped] CHECK CONSTRAINT [FK_tblArticlesGrouped_tblArticles]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblArticlesGrouped_tblGroups]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblArticlesGrouped]'))
ALTER TABLE [dbo].[tblArticlesGrouped]  WITH CHECK ADD  CONSTRAINT [FK_tblArticlesGrouped_tblGroups] FOREIGN KEY([Group_ID])
REFERENCES [dbo].[tblGroups] ([Group_ID])
GO
ALTER TABLE [dbo].[tblArticlesGrouped] CHECK CONSTRAINT [FK_tblArticlesGrouped_tblGroups]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblGroups_tblPublisher]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblGroups]'))
ALTER TABLE [dbo].[tblGroups]  WITH CHECK ADD  CONSTRAINT [FK_tblGroups_tblPublisher] FOREIGN KEY([GroupOwner])
REFERENCES [dbo].[tblPublisher] ([Publisher_ID])
GO
ALTER TABLE [dbo].[tblGroups] CHECK CONSTRAINT [FK_tblGroups_tblPublisher]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblArticles_tblPublisher]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblArticles]'))
ALTER TABLE [dbo].[tblArticles]  WITH CHECK ADD  CONSTRAINT [FK_tblArticles_tblPublisher] FOREIGN KEY([Publisher_ID])
REFERENCES [dbo].[tblPublisher] ([Publisher_ID])
GO
ALTER TABLE [dbo].[tblArticles] CHECK CONSTRAINT [FK_tblArticles_tblPublisher]
